let a=[];
const fs=require("fs");
const ws1=fs.createWriteStream("2排序前.txt","utf-8");
for(let i=0;i<100;i++){
    a[i]=parseInt(Math.random()*1000);
    ws1.write(a[i]+"\n");
}
ws1.end();
for(i=1;i<100;i++){
    let j;
    let t=0;
    for(j=0;j<=i;j++){
        if(a[i]<a[j]){
            t=a[i];
            a[i]=a[j];
            a[j]=t;
            break;
        }
    }
    for(j=j+1;j<=i;j++){
        t=a[i];
        a[i]=a[j];
        a[j]=t;
    }
}
const ws2=fs.createWriteStream("2排序后.txt","utf-8");
for(i=0;i<100;i++){
    ws2.write(a[i]+"\n");
}
ws2.end();